package com.yidu.best.basicSetup.accountset.service.impl;

import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import com.yidu.best.basicSetup.accountset.dao.AccountDao;
import com.yidu.best.basicSetup.accountset.domain.Account;
import com.yidu.best.basicSetup.accountset.domain.AccountVo;
import com.yidu.best.basicSetup.accountset.service.AccountService;
import com.yidu.best.basicSetup.accountset.util.ExcelUtil;
import com.yidu.best.basicSetup.accountset.util.IDUtil;

/**
 * 
 * @author liyikang
 *
 */
@Service
public class AccountServiceImpl implements AccountService {
	@Autowired
	private AccountDao accountDao;

	@Override
	public Map<String, Object> findAccount(AccountVo accountVo) {
		// 调用dao层方法查询数量
		int count = accountDao.findCountAccount(accountVo);
		// 计算页码
		int page = (accountVo.getPage() - 1) * accountVo.getLimit();
		accountVo.setPage(page);
		// 调用dao层方法分页查询
		List<Account> accountList = accountDao.findAccount(accountVo);
		Map<String, Object> map = new HashMap<String, Object>();
		// 将数据存入map中
		map.put("data", accountList);
		map.put("code", 0);
		map.put("msg", "");
		map.put("count", count);
		return map;
	}

	@Override
	public int addAccount(Account account) {
		// 随机一个16位的ID
		account.setAccountId(IDUtil.getUUID());
		// 调用dao层添加方法
		int add = accountDao.addAccount(account);
		return add;
	}

	@Override
	public int updateAccount(Account account) {
		return accountDao.updateAccount(account);
	}

	@Override
	public int deleteAccount(String accountId) {
		return accountDao.deleteAccount(accountId);
	}
	
	/**
	 * 基金表查询现金方法
	 */
	@Override
	public List<Account> findByAllAccount() {
		
		return accountDao.findByAllAccount();
	}

}
